package com.zyf.chapter02.structure.decorator.eureka;

/**
 * 应用上下文启动类
 *
 * 装饰器模式
 *
 * 如此设计满足开闭原则，如果有新的 httpClient，只需增加一个类,并修改这里即可完成新的逻辑调用
 * @author yifeng
 */
public class ApplicationContaxt {
    public static void main(String[] args) {
        RestTemplateTransportClientFactory factory = new RestTemplateTransportClientFactory();
        HttpClientFactory httpClientFactory = new HttpClientFactory() {
            @Override
            public HttpClient newClient() {
                return new SessionedHttpClient(RetrableHttpClient
                    .createFactory(RedirectingHttpClient.createFactory(factory)));
            }
        };
        System.out.println(httpClientFactory.newClient().getApplications());
    }
}
